import request from '@/utils/request';
import axiosUpdate from '@/utils/http';
/* eslint-disable */
// sit地址sit.cxm.gigrt.com
// 本地地址120.77.229.212
// 查询客户联系人列表
//uat环境
const testURL = 'http://10.25.159.199:18080';

const rwsUrl =
  process.env.NODE_ENV === 'development'
    ? 'http://dev.c85eaf0d05d04465a81befded3f4f608b.cn-shenzhen.alicontainer.com'
    : window.location.origin;
// const rwsUrl =
// process.env.NODE_ENV === 'development' ? 'http://120.77.229.212' : 'http://prod.cxm.gigrt.com';
//sit环境
// const rwsUrl =
//   process.env.NODE_ENV === 'development' ? 'http://120.77.229.212' : 'https://sit.cxm.gigrt.com';
// const authorityUrl =
//   process.env.NODE_ENV === 'development' ? 'http://localhost:8080' : window.location.origin;

const xxUrl = 'http://10.25.159.212:18080/';

export function getAssociatesList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customers_associates?customerId=${data.customerId}`
  );
}
// 查询客户联系历史信息
export function getContactHisList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/contact/customers_contact?customerId=${
      data.customerId
    }&currentPage=${data.currentPage}&pageSize=${data.pageSize}`
  );
}
// 查询GR会员卡明细
export function getCfInformation(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/campaign/customers_gr_detail?customerId=${
      data.customerId
    }&memberId=${data.memberId}`
  );
}
// 查询活动日志信息
export function getInteractions(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/campaign/customers_interaction_log?customerId=${
      data.customerId
    }&type=${data.type}&category=${data.category}&currentPage=${data.currentPage}&pageSize=${
      data.pageSize
    }`
  );
}
// 查询客户标签
export function getLabelList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customers_label?customerId=${
      data.customerId
    }`
  );
}
// 查询会员卡信息
export function getMemberList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/campaign/customers_member?customerId=${
      data.customerId
    }&memberType=${data.memberType}`
  );
}
// 查询客户偏好信息
export function getPreferenceInfo(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customersPreference?customerId=${
      data.customerId
    }&type=GAME`
  );
}
// 查询客户明细信息
export function getProfileDetail(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customers_detail?customerId=${
      data.customerId
    }&userId=${data.userId}&notCallExternalSystem=1`
  );
}
export function getCustomerPhoto(data) {
  return axiosUpdate.get(`${rwsUrl}/rwscxm/api/v1/customer/profile/retrieve_member_photo_by_cms?customerId=${data.customerId}`);
}
export function getCustomerMember(data) {
  return axiosUpdate.get(`${rwsUrl}/rwscxm/api/v1/customer/profile/retrieve_member_info_by_cms?customerId=${data.customerId}`);
}
export function getCustomerGame(data) {
  return axiosUpdate.get(`${rwsUrl}/rwscxm/api/v1/customer/profile/retrieve_gaming_info_by_cms?customerId=${data.customerId}`);
}
// 查询客户推荐商品信息
export function getRecommendInfo(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/product/customers_recommend?customerId=${
      data.customerId
    }&type=${data.type}&currentPage=${data.currentPage}&pageSize=${data.pageSize}`
  );
}
// 查询客户统计指标信息
export function getStatisticsList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customers_statistics?customerId=${data.customerId}`
  );
}
// 查询客户hotel概要信息
export function getHotelBookingSummarize(data) {
  return hotelReserveAxios({
    url: `${rwsUrl}/rwscxm/api/v1/hotel/hotelBooking/hotelBookingSummarize`,
    method: 'POST',
    data,
  });
}
// 查询客户vouchers信息
export function getVouchers(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customers_vouchers?customerId=${data.customerId}`
  );
}
// 查询客户会员卡信息
export function getCustomersCardDetail(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customers_card_detail?customerId=${data.customerId}`
  );
}
// 交易中心信息
export function getTransactionLogs(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/transaction/common/get_transaction_logs`,
    method: 'POST',
    data,
  });
}
// 移除用户收藏客户
export function getRemoveList(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/user/favorite/remove_favorite_customers`,
    method: 'POST',
    data,
  });
}
// 新增用户收藏客户
export function getAddList(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/user/favorite/add_favorite_customers`,
    method: 'POST',
    data,
  });
}
// 查询用户权限
export function getUserAuthorities(userId) {
  // 'portal' 用window.AppGlobal.webroot代替
  return axiosUpdate.get(
    `${rwsUrl}${window.AppGlobal.webroot || '/portal'}/components/independents/${userId}`
  );
}
// 查询酒店预定类型
export function getReservationType(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/transaction/common/reservation_type?bookingNum=${data.bookingNum}`
  );
}
//查询当前酒店入住信息
export function getCurrentHotel(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/hotel/customers_current_hotel?customerId=${data.customerId}`
  );
}
//查询景点通行证信息
export function getAttractionPassInfos(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/resource/attraction_pass?customerId=${data.customerId}`
  );
}
//客户实例化属性查询
export function getCustomerAttributeList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/attribute/getCustomerAttrList?customerId=${
      data.customerId
    }&attrType=1010001`
  );
}
//配置属性查询接口
export function getAttributeList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/attribute/getAttributeList?customerId=${
      data.customerId
    }&attrType=1010001`
  );
}
//客户属性修改接口
export function getModifyCustmerAttr(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/customer/attribute/modifyCustomerAttr`,
    method: 'POST',
    data,
  });
}
//客户资料历史轨迹查询
export function getCustomerChangeTracking(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/tracking/getCustomerChangeTracking?objectId=${
      data.objectId
    }&busiType=${data.busiType}&subBusiType=${data.subBusiType}&changeType=${
      data.changeType
    }&changeSubType=${data.changeSubType}&staffId=${data.staffId}&startDate=${
      data.startDate
    }&endDate=${data.endDate}&currentPage=${data.currentPage}&pageSize=${data.pageSize}`
  );
}
//用户rmCode查询
export function getUserRegionsWithRmCodes(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/user/region/getUserRegionsWithRmCodes?userId=${data.userId}`
  );
}
//查询客户偏好信息
export function getCustomersPreference(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/profile/customersPreference?customerId=${data.customerId}`
  );
}
//客户偏好历史查询
export function getPreferenceChangeTracking(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/tracking/getCustomerChangeTracking?objectId=${
      data.objectId
    }&busiType=${data.busiType}&subBusiType=${data.subBusiType}&changeType=${
      data.changeType
    }&changeSubType=${data.changeSubType}&staffId=${data.staffId}&startDate=${
      data.startDate
    }&endDate=${data.endDate}&currentPage=${data.currentPage}&pageSize=${data.pageSize}`
  );
}
//查询客户Other Casino信息
export function getCustomersOtherCasino(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/attribute/getCustomerOtherCasino?customerId=${
      data.customerId
    }`
  );
}

//对于客户中心配置通用配置进行查询
export function getPreferenceConfig(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/config/getCustomerConfig?type=${data.type}`
  );
}
//对于非dataphin的偏好数据可进行信息修改
export function modifyCustomersPreference(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/customer/profile/modifyCustomersPreference`,
    method: 'POST',
    data,
  });
}

//客户属性修改接口
export function getModifyCustmerOtherCasino(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/customer/attribute/modifyCustomerOtherCasino`,
    method: 'POST',
    data,
  });
}
//查询客户Other Casino信息
export function getCustomersOtherCasinoConfig(data) {
  return axiosUpdate.get(`${rwsUrl}/rwscxm/api/v1/customer/config/getCustomerConfig?type=11`);
}

//hotellog 搜索
export function hotelSearch(data) {
  return axiosUpdate({
    //url: `${rwsUrl}/rwscxm/api/v1/hotel/hotelLog/getOperationLogInfo`,
    url: `${rwsUrl}/rwscxm/api/v1/hotel/hotelLog/getOperationLogInfo`,
    method: 'POST',
    data,
  });
}

//查询用户的用户名
export function queryUserNameById(ids) {
  return request(`/rwsUsers/queryUsersByIds?ids=${ids}`);
}

//查询客户EligibilityList信息
export function getEligibilityList(data) {
  const { cxmid } = data;
  // const url = 'http://10.25.159.214:18080/';
  return axiosUpdate({
    // url: `${url}/rwscxm/api/v1/taskOrder/campaign/getEligibilityList?cxmid=${cxmid}`,
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/campaign/getEligibilityList?cxmid=${cxmid}`,
    // url: `/rwscxm/api/v1/taskOrder/campaign/getEligibilityList`,
    method: 'GET',
  });
}
// Attr Config查询
export function getCampaignAttrConfig(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/common/getAttrConfig?attrCode=${data.attrCode}`
  );
}
// const urlTest = "http://10.25.159.225:18080";
//查询客户Other Casino信息
export function getOutstandingList(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/feedBack/getOutTaskList`,
    method: 'POST',
    data,
  });
}

//查询所有配置信息信息
export function getDictionaryConfig(data) {
  const { dictType, dictSubType } = data;
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/taskOrder/common/getDictionaryConfig?dictType=${dictType}&dictSubType=${dictSubType}`
  );
}

//添加setResult
export function setResult(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/feedBack/addCustConsider`,
    method: 'POST',
    data,
  });
}

// compBalance
export function fetchCompBalance(param) {
  return axiosUpdate.get(`${rwsUrl}/rwscxm/api/v1/customer/profile/customers_comp_balance`, {
    params: param,
  });
}

// 查询NBO标签
export function getNBOList(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/customer/attribute/getCustomerAttrList?attrType=3000001&customerId=${
      data.customerId
      }`
  );
}
// getContactHistory
export function getContactHistory(data) {
  const {channel='',type='',startTime:beginTime='',endTime='',currentPage=1,pageSize=5,customerId:cxmId=''}=data;
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/genesys/contact/list?channel=${channel}&type=${type}&beginTime=${beginTime}&endTime=${endTime}&currentPage=${currentPage}&pageSize=${pageSize}&cxmId=${cxmId}`
  );
}
// getContactDropDownList
export function getContactDropDownList(functionType) {
  return axiosUpdate.get(`${rwsUrl}/rwscxm/api/v1/communiction/callInfo/getContactDropDownList?functionType=${functionType}`);
}

// getContactDics
export function getContactDics(functionType) {
  return axiosUpdate.get(`${rwsUrl}/rwscxm/api/v1/genesys/contact/dics?dicType=${functionType}`);
}

// modifyContactHistory
export function modifyContactHistory(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/communiction/callInfo/modifyContactReason`,
    method: 'POST',
    data,
  });
}
// getContactReasonHistory
export function getContactReasonHistory(uccid) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/communiction/callInfo/getContactReasonHistory?uccid=${uccid}`,
    method: 'GET',
  });
}
// queryPhoneNum
export function queryPhoneNum(timeStamp) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/communiction/callInfo/queryPhoneNum?timeStamp=${timeStamp}`,
    method: 'GET',
  });
}
// makeCall
export function makeCall(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/communiction/callInfo/makeCall`,
    method: 'POST',
    data
  });
}
// getContactReason
export function getContactReason(uccid) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/communiction/callInfo/getContactReason?uccid=${uccid}`,
    method: 'GET',
  });
}
// createListRecord
export function createListRecord(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/communiction/callInfo/createListRecord`,
    method: 'POST',
    data
  });
}

//getOutstandingList
export function getManualOutstandingList(data) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/feedBack/getOutstandingTaskList`,
    method: 'POST',
    data,
  });
}

// userGrouping
export function queryUserGroupsWithMembers(data) {
  return axiosUpdate.get(
    `${rwsUrl}/rwscxm/api/v1/user/group/queryUserGroupsWithMembers?groupType=${data.groupType}`
  );
}

export async function queryMenus(portalId = 1) {
  return request(`/users/portals/${portalId}/dirmenus`);
}

export function modifyActivityStatus(params) {
  return axiosUpdate({
    url: `${rwsUrl}/rwscxm/api/v1/taskOrder/profile/modifyOrderStatus`,
    method: 'POST',
    data: { ...params },
  });
}
